window: Properly detect if size allocation is needed
authorBenjamin Otte <otte@redhat.com>
Tue, 12 Feb 2019 01:20:36 +0000 (02:20 +0100)
committerBenjamin Otte <otte@redhat.com>
Fri, 15 Feb 2019 05:46:04 +0000 (06:46 +0100)
Instead of looking at the allocation, just look at the alloc_needed
widget flag that tracks if an allocation is needed.

gtk/gtkwindow.c

index db108c8a2d115a48ada336a5ae37309b2ec7bf29..b101fc7376394e493565c6f58f63794bfed7c73f 100644 (file)
@@ -6385,13 +6385,8 @@ gtk_window_realize (GtkWidget *widget)
   if (!priv->client_decorated && gtk_window_should_use_csd (window))
     create_decoration (widget);
 
-  _gtk_widget_get_allocation (widget, &allocation);
-
   /* ensure widget tree is properly size allocated */
-  if (allocation.x == -1 &&
-      allocation.y == -1 &&
-      allocation.width == 1 &&
-      allocation.height == 1)
+  if (_gtk_widget_get_alloc_needed (widget))
     {
       GdkRectangle request;
 
@@ -6408,16 +6403,15 @@ gtk_window_realize (GtkWidget *widget)
       g_return_if_fail (!_gtk_widget_get_realized (widget));
     }
 
+  _gtk_widget_get_allocation (widget, &allocation);
+
   if (priv->hardcoded_surface)
     {
       surface = priv->hardcoded_surface;
-      _gtk_widget_get_allocation (widget, &allocation);
       gdk_surface_resize (surface, allocation.width, allocation.height);
     }
   else
     {
-      _gtk_widget_get_allocation (widget, &allocation);
-
       switch (priv->type)
         {
         case GTK_WINDOW_TOPLEVEL: